package cn.kz.hrm.rabbitmqmessagerecive;

import cn.kz.hrm.config.RabbitmqConfig;
import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * rabbitMQ的消息接收者
 */
@Component
public class RabbitMQMessageRecive {

    @RabbitListener(queues = RabbitmqConfig.QUENE_NAME_EMAIL)
    public void emailMessageHandler(String courseName, Message message, Channel channel){
        //1.准备消息
        String courseMessage = "邮件发送：你期待已久的"+courseName+"的新课程上线了！，赶快点击链接订阅吧！！";
        //2.去用户(门户网站用户)表查询用户的邮箱：待定
        //3.发送邮件
        System.out.println(courseMessage);
    }

    @RabbitListener(queues = RabbitmqConfig.QUENE_NAME_SYSTEM)
    public void systemMessageHandler(String courseName, Message message, Channel channel){
        //1.准备消息
        String courseMessage = "站内信发送：你期待已久的"+courseName+"的新课程上线了！，赶快点击链接订阅吧！！";
        //2.去用户(门户网站用户)表查询用户的邮箱：待定
        //3.发送站内信
        System.out.println(courseMessage);
    }

    @RabbitListener(queues = RabbitmqConfig.QUENE_NAME_SMS)
    public void smsMessageHandler(String courseName, Message message, Channel channel){
        //1.准备消息
        String courseMessage = "短信发送：你期待已久的"+courseName+"的新课程上线了！，赶快点击链接订阅吧！！";
        //2.去用户(门户网站用户)表查询用户的邮箱：待定
        //3.发送短信
        System.out.println(courseMessage);
    }
}
